﻿using FluentNHibernate.Mapping;
using Romantics.Domain.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Romantics.Domain.Mappings
{
    class HikeMap : ClassMap<Hike>
    {
        public HikeMap()
        {
            Id(x => x.ID);

            Map(x => x.Name)
                .Length(200)
                .Not.Nullable();

            Map(x => x.Description)
                .CustomType("StringClob")
                .CustomSqlType("NVARCHAR(MAX)");

            Map(x => x.Meta)
                .CustomType("StringClob")
                .CustomSqlType("NVARCHAR(MAX)");

            Map(x => x.ShortDescription)
                .Column("SHORT_DESCRIPTION")
                .Length(500)
                .Not.Nullable();

            Map(x => x.Route);

            Map(x => x.StartDate)
                .Column("START_DATE")
                .CustomSqlType("DATE")
                .Not.Nullable();

            Map(x => x.EndDate)
                .Column("END_DATE")
                .CustomSqlType("DATE")
                .Not.Nullable();

            Map(x => x.Published)
                .Column("PUBLISHED")
                .Not.Nullable();

            Map(x => x.Duration)
                .CustomSqlType("INT")
                .Not.Insert()
                .Not.Update()
                .Not.Nullable();

            References(x => x.Category)
                .Column("CATEGORY_ID")
                .Not.Nullable();

            References(x => x.Region)
                .Column("REGION_ID")
                .Not.Nullable();

            HasMany(x => x.PhotoAlbums)
                .Inverse()
                .KeyColumn("HIKE_ID");

            HasMany(x => x.Reports)
                .Inverse()
                .KeyColumn("HIKE_ID");
        }
    }
}
